import java.util.concurrent.Semaphore;

public class Demo14 {

    public static void main(String[] args) throws InterruptedException {
        //指定可用资源数为 4
        Semaphore semaphore = new Semaphore(4);

        semaphore.acquire();
        System.out.println("进行一次P操作");
        semaphore.acquire();
        System.out.println("进行一次P操作");
        semaphore.acquire();
        System.out.println("进行一次P操作");
        semaphore.acquire();
        System.out.println("进行一次P操作");
        semaphore.acquire();
        System.out.println("进行一次P操作");


    }
}

